﻿namespace com.stifel.BranchMgmtDao
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Serialization;

    using com.stifel.common;
    using com.stifel.Extensions.ObjectExtensions;
    using com.stifel.Extensions.StringExtensions;

    public partial class StifelBranchPromotionWorklist
    {
        #region Fields

        WorkListDetail _Detail;

        #endregion Fields

        #region Properties

        public WorkListDetail Detail
        {
            get
            {
                _Detail = WorkListDetail.Deserialize( PromotionDetails );
                return _Detail;
            }
            set
            {
                PromotionDetails = value.Serialize( );
            }
        }

        #endregion Properties

        #region Methods

        public WorkListDetail GetDetail( )
        {
            return WorkListDetail.Deserialize( PromotionDetails );
        }

        public void SetDetail( WorkListDetail value )
        {
            PromotionDetails = value.Serialize( );
        }

        #endregion Methods

        #region Nested Types

        [Serializable]
        public class StifelBranchInfo
        {
            #region Properties

            public string BranchLocationIdentifier
            {
                get;
                set;
            }

            public int Id
            {
                get;
                set;
            }

            public Guid UniqueId
            {
                get;
                set;
            }

            #endregion Properties
        }

        [Serializable]
        [XmlRoot( "root" )]
        public class WorkListDetail
        {
            #region Fields

            StifelBranchInfo _BranchInfo;
            List<Guid> _BranchLease;
            List<Guid> _BranchPersonnel;
            List<Guid> _BranchUnit;
            List<Guid> _BranchUpdate;
            List<Guid> _BranchVendor;
            List<Guid> _Hardware;
            List<Guid> _NetworkEquipment;
            List<Guid> _Photo;
            List<Guid> _TelephoneSystem;

            #endregion Fields

            #region Properties

            public StifelBranchInfo BranchInfo
            {
                get
                {
                    if ( _BranchInfo == null )
                        _BranchInfo = new StifelBranchInfo( );
                    return _BranchInfo;
                }
                set
                {
                    _BranchInfo = value;
                }
            }

            public List<Guid> BranchLease
            {
                get
                {
                    if ( _BranchLease == null )
                        _BranchLease = new List<Guid>( );
                    return _BranchLease;
                }
                set
                {
                    _BranchLease = value;
                }
            }

            public List<Guid> BranchPersonnel
            {
                get
                {
                    if ( _BranchPersonnel == null )
                        _BranchPersonnel = new List<Guid>( );
                    return _BranchPersonnel;
                }
                set
                {
                    _BranchPersonnel = value;
                }
            }

            public List<Guid> BranchUnit
            {
                get
                {
                    if ( _BranchUnit == null )
                        _BranchUnit = new List<Guid>( );
                    return _BranchUnit;
                }
                set
                {
                    _BranchUnit = value;
                }
            }

            public List<Guid> BranchUpdate
            {
                get
                {
                    if ( _BranchUpdate == null )
                        _BranchUpdate = new List<Guid>( );
                    return _BranchUpdate;
                }
                set
                {
                    _BranchUpdate = value;
                }
            }

            public List<Guid> BranchVendor
            {
                get
                {
                    if ( _BranchVendor == null )
                        _BranchVendor = new List<Guid>( );
                    return _BranchVendor;
                }
                set
                {
                    _BranchVendor = value;
                }
            }

            public List<Guid> Hardware
            {
                get
                {
                    if ( _Hardware == null )
                        _Hardware = new List<Guid>( );
                    return _Hardware;
                }
                set
                {
                    _Hardware = value;
                }
            }

            public List<Guid> NetworkEquipment
            {
                get
                {
                    if ( _NetworkEquipment == null )
                        _NetworkEquipment = new List<Guid>( );
                    return _NetworkEquipment;
                }
                set
                {
                    _NetworkEquipment = value;
                }
            }

            public List<Guid> Photo
            {
                get
                {
                    if ( _Photo == null )
                        _Photo = new List<Guid>( );
                    return _Photo;
                }
                set
                {
                    _Photo = value;
                }
            }

            public List<Guid> TelephoneSystem
            {
                get
                {
                    if ( _TelephoneSystem == null )
                        _TelephoneSystem = new List<Guid>( );
                    return _TelephoneSystem;
                }
                set
                {
                    _TelephoneSystem = value;
                }
            }

            #endregion Properties

            #region Methods

            public static WorkListDetail Deserialize( string value )
            {
                string STARTTAG = "<root>".HtmlEncode( );
                string ENDTAG = "</root>".HtmlEncode( );
                string l = string.Empty;
                if ( !string.IsNullOrEmpty( value ) )
                {
                    int a = value.IndexOf( STARTTAG );
                    int b = value.IndexOf( ENDTAG ) + ENDTAG.Length;
                    int c = value.Length;
                    l = value.Substring( a, c - a - ( c - b ) );
                }
                WorkListDetail wl = null;
                if ( !string.IsNullOrEmpty( l ) )
                    wl = WorkListDetail.deserialize( l );
                if ( wl == null )
                    wl = new WorkListDetail( );
                return wl;
            }

            public string Serialize( )
            {
                return this.SerializeToXml<WorkListDetail>( ).HtmlEncode( );
            }

            static WorkListDetail deserialize( string xmlValue )
            {
                return xmlValue.HtmlDecode( ).DeserializeFromXml<WorkListDetail>( );
            }

            #endregion Methods
        }

        #endregion Nested Types
    }
}